const ProjectRequest = require("../project/project_request.js");
const Url = require("../utils/url.js");

function page(startPage, callback){
  const URL = Url.newInstance("/address/page");
  URL.setPara('startPage', startPage)
  ProjectRequest.getRequest(URL.get(), callback);
}

function list(callback) {
  const URL = Url.newInstance("/address/list");
  ProjectRequest.getRequest(URL.get(), callback);
}

function findById(id, callback) {
  const url = "/address/" + id;
  ProjectRequest.getRequest(url, callback);
}

function gainDefault(callback) {
  const url = "/address/get/default";
  ProjectRequest.getRequest(url, callback);
}

function deleteById(id, callback) {
  const url = "/address/delete/" + id;
  ProjectRequest.deleteRequest(url, callback);
}

function add(data, callback) {
  const url = "/address/add/"
  ProjectRequest.postRequest(url, data, callback);
}

function edit(id, data, callback) {
  const url = "/address/edit/" + id;
  ProjectRequest.putRequest(url, data, callback);
}

module.exports = {
  page,
  list,
  findById,
  deleteById,
  add,
  edit,
  gainDefault
};